<?php

namespace Common\Controller;

use Think\Controller;

class BaseController extends Controller
{
    public function _initialize()
    {
        $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
        if (in_array($origin, C('ALLOW_ORIGIN'))) {
            header('Access-Control-Allow-Origin:' . $origin);
            header('Access-Control-Allow-Credentials:true');
            header('Access-Control-Allow-Methods:PUT,POST,GET,DELETE,OPTIONS');
        }
    }
}